<?php
namespace App\Controllers;
use \interop\Container\ContainerInterface as ContainerInterface;
use App\Models\UserModel;
use pdo;
class UserController extends BaseController{
	public function home(){
		if($_SESSION['loginName']){
			 include APP_PATH.'/Views/home/mainindex.html';
		}
		else{
			include APP_PATH.'/Views/home/login.html';
		}
	}
	public function login(){
        include APP_PATH.'/Views/home/login.html';
	}
	public function postlogin($request,$respone,$args){
		$name = $request->getParam('username');
	    $pas = $request->getParam('pas');
	    $user=new UserModel();
	    if($user->getUserInfo($name,$pas)){
	    	$data=array('massage'=>'成功','code'=>0);
	    	$_SESSION['loginName']=$name;
	    }
	    else{
	    	$data=array('message'=>'用户名或密码不正确','code'=>101);
	    }
	    return $respone->withJson($data); 
	}
	public function logoff($request,$respone,$args){
		 unset($_SESSION['loginName']);
		if(!$_SESSION['loginName']){
			 include APP_PATH.'/Views/home/login.html';
		}
	}
	public function announceList($request,$respone,$args){
		include APP_PATH.'/Views/pages/announce/announce_list.html';
	}
	public function customerManagement($request,$respone,$args){
		include APP_PATH.'/Views/pages/customer/cusomer_management.html';
	}
	public function distributedList($request,$respone,$args){
		include APP_PATH.'/Views/pages/distribute/distributed_list.html';
	}
	public function employeeList($request,$respone,$args){
		include APP_PATH.'/Views/pages/employee/employee_list.html';
	}
	public function flowerShowlist($request,$respone,$args){
		include APP_PATH.'/Views/pages/flower/flower_showlist.html';
	}
	public function flowerStocklist($request,$respone,$args){
		include APP_PATH.'/Views/pages/flower/flower_stocklist.html';
	}
	public function orderedList($request,$respone,$args){
		include APP_PATH.'/Views/pages/order/ordered_list.html';
	}
	public function roleManagement($request,$respone,$args){
		include APP_PATH.'/Views/pages/role/role_management.html';
	}
	public function undistributeList($request,$respone,$args){
		include APP_PATH.'/Views/pages/distribute/undistribute_list.html';
	}
	public function unorderList($request,$respone,$args){
		include APP_PATH.'/Views/pages/order/unorder_list.html';
	}
	public function main($request,$respone,$args){
		include APP_PATH.'/Views/pages/main.html';
	}
	public function logSystemlist($request,$respone,$args){
		include APP_PATH.'/Views/pages/log/log_systemlist.html';
	}
	public function logBusinesslist($request,$respone,$args){
		include APP_PATH.'/Views/pages/log/log_businesslist.html';
	}
	public function lunbotu($request,$respone,$args){
		include APP_PATH.'/Views/pages/lunbo/lunbo_management.html';
	}
	public function xianshi($request,$respone,$args){
		include APP_PATH.'/Views/pages/xianshi/xianshi_management.html';
	}
	public function distributing($request,$respone,$args){
		include APP_PATH.'/Views/pages/distribute/distributing_list.html';
	}
	public function cake($request,$respone,$args){
		include APP_PATH.'/Views/pages/cake/cake_management.html';
	}
	public function getmenu($request,$respone,$args){
		$username=$request->getParam('username');
		$user=new UserModel();
		$ret=json_encode($user->getusermenu($username));
		if($user->getusermenu($username)){
			$result=$ret;
		}
		else{
			$result=a;
		}
		return $result;
	}
	public function getname($request,$respone,$args){
		$username=$request->getParam('username');
		$user=new UserModel();
		$ret=$user->getusername($username);
		if($user->getusername($username)){
			$result=json_encode($ret);
		}
		else{
			$result=a;
		}
		return $result;
	}
	public function goodList($request,$respone,$args){
		$data="111";
		return $data;
	}
}